import type { AxiosRequestConfig, AxiosResponse } from 'axios'

// 注意这里的泛型T, 是为适配单个请求的响应拦截处理
export interface CYRequestInterceptors<T = AxiosResponse> {
  // TS定义函数类型语法
  requestInterceptor?: (config: AxiosRequestConfig) => AxiosRequestConfig
  requestInterceptorCatch?: (error: any) => any
  responseInterceptor?: (config: T) => T
  responseInterceptorCatch?: (error: any) => any
}

// 继承AxiosRequestConfig并拓展了拦截器属性
export interface CYRequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  // 拦截器参数可选
  interceptors?: CYRequestInterceptors<T>
  // 是否显示loading状态
  showLoading?: boolean
}
